package co.fitstart.weapp.api.dao;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;

import co.fitstart.entity.site.Site;

/**
 * 
 * @author haiyan_xiao
 *
 */
@Dao("hibernate")
public interface SiteDao {

    /**
     * 根据当前门店城市等级和区域等级获取可选门店
     * @param cityLevel
     * @param areaLevel
     * @return
     */
    @Query("FROM Site WHERE disabled = false AND (area.cityLevel > :cityLevel OR (area.cityLevel = :cityLevel AND area.areaLevel >= :areaLevel)) ORDER BY city,district")
    public List<Site> listAvailableSite(@Variable("cityLevel") int cityLevel, @Variable("areaLevel") int areaLevel);

    /**
     * 
     * @return
     */
    @Query("SELECT appointStartHour FROM Site WHERE disabled = false ORDER BY appointStartHour ASC")
    public String getEarliestAppointStartHour();

    /**
     * 
     * @return
     */
    @Query("FROM Site WHERE disabled = false")
    public List<Site> list();
}
